package cn.xanderye.feign.consumer.controller;

import cn.xanderye.feign.consumer.entity.User;
import cn.xanderye.feign.consumer.service.HelloService;
import cn.xanderye.feign.consumer.service.RefactorHelloService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;


/**
 * Created on 2019/12/25.
 *
 * @author 叶振东
 */
@RestController
public class ConsumerController {
    @Autowired
    private HelloService helloService;

    @Autowired
    private RefactorHelloService refactorHelloService;

    @GetMapping("feign-consumer")
    public String helloConsumer() {
        return helloService.hello();
    }

    @GetMapping("feign-consumer2")
    public String helloConsumer2() {
        StringBuilder sb = new StringBuilder();
        sb.append(helloService.hello()).append("\n");
        sb.append(helloService.hello("DIDI")).append("\n");
        sb.append(helloService.hello("DIDI", 30)).append("\n");
        sb.append(helloService.hello(new User("DIDI", 30))).append("\n");
        System.out.println(sb.toString());
        return sb.toString();
    }

    @GetMapping("feign-consumer3")
    public String helloConsumer3() {
        StringBuilder sb = new StringBuilder();
        sb.append(refactorHelloService.hello("DIDI")).append("\n");
        sb.append(refactorHelloService.hello("DIDI", 30)).append("\n");
        sb.append(refactorHelloService.hello(new cn.xanderye.hello.service.api.dto.User("DIDI", 30))).append("\n");
        System.out.println(sb.toString());
        return sb.toString();
    }
}
